<?php

declare(strict_types=1);

namespace App\Websocket;

use Psr\EventDispatcher\EventDispatcherInterface;
use Swoole\Server as SwooleServer;
use App\Event\WebsocketConnectEvent;

class WebSocketEventHandler
{
    protected EventDispatcherInterface $dispatcher;

    public function __construct(EventDispatcherInterface $dispatcher)
    {
        $this->dispatcher = $dispatcher;
    }

    public function onStart(SwooleServer $server): void
    {
        $this->dispatcher->dispatch(new WebsocketConnectEvent($server));
    }
}
